package com.example.demo.controller;

import com.example.demo.entity.Course;
import com.example.demo.entity.Teacher;
import com.example.demo.service.CourseService;
import com.example.demo.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class CourseController {

    @Autowired
    CourseService courseService;

    @PostMapping("/course")
    public int save(@RequestBody Course course){
        return courseService.save(course);
    }

    @DeleteMapping("/course/{courseId}")
    public int delete(@PathVariable("courseId") int courseId){
        return courseService.delete(courseId);
    }

    @PutMapping("/course")
    public int update(@RequestBody Course course){
        return courseService.update(course);
    }

    @GetMapping("/course")
    public List<Course> select(){
        return courseService.select();
    }
}
